Skip to content

[mlir][emitc] Simplify emitc::isSupportedFloatType (NFC) #152464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 7, 2025

Conversation

EtoAndruwa
Copy link
Contributor

@EtoAndruwa EtoAndruwa commented Aug 7, 2025

The switch case code was simplified using LLVM_FALLTHROUGH.

@llvmbot
Copy link
Member

llvmbot commented Aug 7, 2025

@llvm/pr-subscribers-mlir-emitc

@llvm/pr-subscribers-mlir

Author: Andrey Timonin (EtoAndruwa)

Changes

The switch case code was simplified using LLVM_FALLTHROUGH.


Full diff: https://github.com/llvm/llvm-project/pull/152464.diff

1 Files Affected:

  • (modified) mlir/lib/Dialect/EmitC/IR/EmitC.cpp (+5-5)
diff --git a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
index e6a3154721faa..e5783ab84bad1 100644
--- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
+++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/TypeSwitch.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/Compiler.h"
 
 using namespace mlir;
 using namespace mlir::emitc;
@@ -114,11 +115,10 @@ bool mlir::emitc::isIntegerIndexOrOpaqueType(Type type) {
 bool mlir::emitc::isSupportedFloatType(Type type) {
   if (auto floatType = llvm::dyn_cast<FloatType>(type)) {
     switch (floatType.getWidth()) {
-    case 16: {
-      if (llvm::isa<Float16Type, BFloat16Type>(type))
-        return true;
-      return false;
-    }
+    case 16:
+      if (!llvm::isa<Float16Type, BFloat16Type>(type))
+        return false;
+      LLVM_FALLTHROUGH;
     case 32:
     case 64:
       return true;

@joker-eph joker-eph changed the title [mlir][emitc] Use LLVM_FALLTHROUGH [mlir][emitc] Use LLVM_FALLTHROUGH (NFC) Aug 7, 2025
@EtoAndruwa EtoAndruwa force-pushed the use-fallthrough-emitc branch from 5700531 to a00761f Compare August 7, 2025 15:13
@EtoAndruwa EtoAndruwa changed the title [mlir][emitc] Use LLVM_FALLTHROUGH (NFC) [mlir][emitc] Simplify emitc::isSupportedFloatType (NFC) Aug 7, 2025
@joker-eph joker-eph merged commit 3fbb553 into llvm:main Aug 7, 2025
9 checks passed
@joker-eph
Copy link
Collaborator

LG

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants